package cn.westv.scps.domain;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.codehaus.jackson.annotate.JsonBackReference;
import org.hibernate.annotations.GenericGenerator;

/**
 * Created by Administrator on 2017/08/01.
 */
@Entity(name = "sys_dict_item")
// @Table(name = "sys_dict_item")
public class SysDictItem implements Serializable {
	private String itemId;// 主键
	// private String dictId;// 外键关联字典
	private String itemCode;//
	private String itemName;// 值的名称
	private String itemValue;// 编码中实际的值
	private String itemEnable;// 是否可用 “1” 可用 ,“0”不可用
	private Integer itemRank;// 排序
	@JsonBackReference
	private SysDict sysDict;

	@Id
	@Column(name = "ITEM_ID")
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid")
	public String getItemId() {
		return itemId;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	// @Basic
	// @Column(name = "DICT_ID")
	// public String getDictId() {
	// return dictId;
	// }
	//
	// public void setDictId(String dictId) {
	// this.dictId = dictId;
	// }

	@Basic
	@Column(name = "ITEM_CODE")
	public String getItemCode() {
		return itemCode;
	}

	public void setItemCode(String itemCode) {
		this.itemCode = itemCode;
	}

	@Basic
	@Column(name = "ITEM_NAME")
	public String getItemName() {
		return itemName;
	}

	public void setItemName(String itemName) {
		this.itemName = itemName;
	}

	@Basic
	@Column(name = "ITEM_VALUE")
	public String getItemValue() {
		return itemValue;
	}

	public void setItemValue(String itemValue) {
		this.itemValue = itemValue;
	}

	@Basic
	@Column(name = "ITEM_ENABLE")
	public String getItemEnable() {
		return itemEnable;
	}

	public void setItemEnable(String itemEnable) {
		this.itemEnable = itemEnable;
	}

	@Basic
	@Column(name = "ITEM_RANK")
	public Integer getItemRank() {
		return itemRank;
	}

	public void setItemRank(Integer itemRank) {
		this.itemRank = itemRank;
	}

	@ManyToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "server_id")
	// @JsonIgnore
	public SysDict getSysDict() {
		return sysDict;
	}

	// @JsonIgnore
	public void setSysDict(SysDict sysDict) {
		this.sysDict = sysDict;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		SysDictItem that = (SysDictItem) o;

		if (itemId != null ? !itemId.equals(that.itemId) : that.itemId != null)
			return false;
		// if (dictId != null ? !dictId.equals(that.dictId) : that.dictId !=
		// null)
		// return false;
		if (itemCode != null ? !itemCode.equals(that.itemCode) : that.itemCode != null)
			return false;
		if (itemName != null ? !itemName.equals(that.itemName) : that.itemName != null)
			return false;
		if (itemValue != null ? !itemValue.equals(that.itemValue) : that.itemValue != null)
			return false;
		if (itemEnable != null ? !itemEnable.equals(that.itemEnable) : that.itemEnable != null)
			return false;
		return itemRank != null ? itemRank.equals(that.itemRank) : that.itemRank == null;
	}

	@Override
	public int hashCode() {
		int result = itemId != null ? itemId.hashCode() : 0;
		// result = 31 * result + (dictId != null ? dictId.hashCode() : 0);
		result = 31 * result + (itemCode != null ? itemCode.hashCode() : 0);
		result = 31 * result + (itemName != null ? itemName.hashCode() : 0);
		result = 31 * result + (itemValue != null ? itemValue.hashCode() : 0);
		result = 31 * result + (itemEnable != null ? itemEnable.hashCode() : 0);
		result = 31 * result + (itemRank != null ? itemRank.hashCode() : 0);
		return result;
	}
}
